package special;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Random;

class Solution3 {
    int[] start;
    int[] rand;
    Random r = new Random();
    public Solution3(int[] nums) {
        start = nums;
        rand = Arrays.copyOf(start, start.length);
    }
    
    public int[] reset() {
        System.arraycopy(start, 0, rand, 0, start.length);
        return rand;
    }
    
    public int[] shuffle() {
        LinkedList<Integer> list = new LinkedList<>();
        for (int num : rand) {
            list.add(num);
        }
        int i = 0;
        while (!list.isEmpty()){
            int index = r.nextInt(list.size());
            rand[i++] = list.get(index);
            list.remove(index);
        }
        return rand;
    }
}